﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MuXue.Zyiz.Template.Domain.Model;
using MuXue.Zyiz.Template.Domain.Model.Request;
using MuXue.Zyiz.Template.Service;
using Microsoft.Extensions.Logging;
using MuXue.Zyiz.Template.Common;
using MuXue.Zyiz.Template.Domain.Entity;
using MuXue.Zyiz.Template.Domain.Model.response;
using Microsoft.AspNetCore.Authorization;

namespace MuXue.Zyiz.Template.WebApi.Controllers
{
    /// <summary>
    /// 【Demo可删除】订单处理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
   
    public class DemoController : ControllerBase
    {
        private ILogger _logger;
        private IordersService _ordersService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="ordersService"></param>
        /// <param name="logger"></param>
        public DemoController(IordersService ordersService, ILogger<DemoController> logger)
        {
            _logger = logger;
            _ordersService = ordersService;

        }



        /// <summary>
        /// 获取订单列表数据
        /// </summary>
        /// <param name="userreq">app用户id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result<List<SmallOrderResp>>> QueryList(OrderListSearchReq userreq)
        { 
             Result<List<SmallOrderResp>> dataList = await _ordersService.GetList(userreq.userid);
               
            return dataList;
        }

        
        /// <summary>
        /// 查询订单详情
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result<OrderDetailResp>>  Detail(OrderDetailReq req)
        {
            Result<OrderDetailResp> result = await _ordersService.QueryDetailByOrderNo(req.app_user_id,  req.order_no);

            return result;
        }
         
    }
}
